Minimal polynomial of matrices